﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class Health : MonoBehaviour
{
    public GameObject privacyPanel;
    // Start is called before the first frame update
    private void Awake()
    {
        transform.Find("splansh/著作权人").GetComponent<Text>().text = AdManager.Owner;
        transform.Find("splansh/登记号").GetComponent<Text>().text = AdManager.License;
        transform.Find("splansh/适龄").Find(AdManager.AgeLimit.ToString()).gameObject.SetActive(true);
#if UNITY_ANDROID
        Next();
#endif
        if (!AdManager.IsOpenWorkTimeShield)
            PlayerPrefs.SetInt("YinSi", 1);
        CheckYinSi();
    }

    // Update is called once per frame
    void Update()
    {

    }

    void Next()
    {
        SceneManager.LoadScene(1);
    }

    public void CheckYinSi()
    {
        if (PlayerPrefs.GetInt("YinSi") == 1)
        {
            privacyPanel.GetComponent<PrivacyPanel>().ClosePrivacy();
            Invoke("Next", 2);
        }
        else
        {
            privacyPanel.SetActive(true);
            privacyPanel.GetComponent<PrivacyPanel>().ShowPrivacy();
        }
    }

    public void Refuse()
    {
        AdManager.Instance.Quit();
    }
}
